import { CreateWindowOptions } from '@renderer/types/createWindow'
import { defineStore } from 'pinia'

export const useProjectFileStore = defineStore('projectFile', {
  state: () => ({
    //当前文件列表
    projectFileList: [
      {
        id: 'canvas',
        name: '画布数据.json',
        type: 'json',
        icon: 'svgIcon'
      },
      {
        id: 'svg',
        name: 'SVG图标.json',
        type: 'json',
        icon: 'svgIcon'
      },
      {
        id: 'randomFun',
        name: '随机函数.json',
        type: 'json',
        icon: 'svgIcon'
      }
    ] as any[]
  }),
  actions: {
    //点击事件
    clickProjectFile(item: any) {
      if (item.id === 'canvas') {
        const obj = {} as CreateWindowOptions
        obj.key = 'jsonData'
        obj.title = '画布数据'
        obj.data = 'canvas'
        window.electron.ipcRenderer.send('openChild', obj)
      }
    }
  }
})
